package com.wenda.admin.core;

import com.wenda.admin.vo.FlowQueryVo;
import org.apache.commons.lang3.StringUtils;

public class StatisticProvider {

    public String statistic(FlowQueryVo query){
        String sql = "SELECT protocol,count(id) as num FROM tb_flow WHERE 1=1";
        if(query != null){
            if(StringUtils.isNotBlank(query.getStartTime())){
                sql = sql + " AND create_time >= #{startTime}";
            }
            if(StringUtils.isNotBlank(query.getEndTime())){
                sql = sql + " AND create_time <= #{endTime}";
            }
        }
        return sql + " GROUP BY protocol";
    }
}
